package com.ylsk.check.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ylsk.check.domain.dto.EntryReportDTO;
import com.ylsk.check.domain.so.EntryReportSO;
import com.ylsk.check.domain.vo.EntryReportVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ylsk.common.annotation.Log;
import com.ylsk.common.core.controller.BaseController;
import com.ylsk.common.core.domain.AjaxResult;
import com.ylsk.common.enums.BusinessType;
import com.ylsk.check.domain.EntryReport;
import com.ylsk.check.service.IEntryReportService;
import com.ylsk.common.utils.poi.ExcelUtil;
import com.ylsk.common.core.page.TableDataInfo;

/**
 * 进场上报Controller
 *
 * @author yangsy
 * @date 2023-12-20
 */
@RestController
@RequestMapping("/check/entryReport")
public class EntryReportController extends BaseController
{
    @Autowired
    private IEntryReportService entryReportService;

    /**
     * 查询进场上报列表
     */
    @PreAuthorize("@ss.hasPermi('check:entryReport:list')")
    @GetMapping("/list")
    public TableDataInfo list(EntryReportSO entryReportSO)
    {
        startPage();
        List<EntryReportVO> list = entryReportService.selectEntryReportList(entryReportSO);
        return getDataTable(list);
    }

    /**
     * 导出进场上报列表
     */
    @PreAuthorize("@ss.hasPermi('check:entryReport:export')")
    @Log(title = "进场上报", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EntryReportSO entryReportSO)
    {
        List<EntryReportVO> list = entryReportService.selectEntryReportList(entryReportSO);
        ExcelUtil<EntryReportVO> util = new ExcelUtil<EntryReportVO>(EntryReportVO.class);
        util.exportExcel(response, list, "进场上报数据");
    }

    /**
     * 获取进场上报详细信息
     */
    @PreAuthorize("@ss.hasPermi('check:entryReport:query')")
    @GetMapping(value = "/{entryReportId}")
    public AjaxResult getInfo(@PathVariable("entryReportId") Long entryReportId)
    {
        return success(entryReportService.selectEntryReportByEntryReportId(entryReportId));
    }

    /**
     * 新增进场上报
     */
    @PreAuthorize("@ss.hasPermi('check:entryReport:add')")
    @Log(title = "进场上报", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EntryReportDTO entryReportDTO)
    {
        return toAjax(entryReportService.insertEntryReport(entryReportDTO));
    }

    /**
     * 修改进场上报
     */
    @PreAuthorize("@ss.hasPermi('check:entryReport:edit')")
    @Log(title = "进场上报", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EntryReportDTO entryReportDTO)
    {
        return toAjax(entryReportService.updateEntryReport(entryReportDTO));
    }

    /**
     * 删除进场上报
     */
    @PreAuthorize("@ss.hasPermi('check:entryReport:remove')")
    @Log(title = "进场上报", businessType = BusinessType.DELETE)
	@DeleteMapping("/{entryReportIds}")
    public AjaxResult remove(@PathVariable Long[] entryReportIds)
    {
        return toAjax(entryReportService.deleteEntryReportByEntryReportIds(entryReportIds));
    }
}
